﻿using Grpc.Net.Client;
using Nuctech.DIS.Publisher;
using System.Diagnostics;
using System.Net.Security;

internal class Program
{
    private static void Main(string[] args)
    {
        try
        {
            #region 方法一
            var grpcChannel = GrpcChannel.ForAddress("http://localhost:22002", new GrpcChannelOptions
            {
                MaxReceiveMessageSize = 100 * 1024 * 1024,
                MaxSendMessageSize = 100 * 1024 * 1024
            });

            //var state = grpcChannel.State;
            #endregion

            //var grpcChannel = GrpcChannel.ForAddress("http://localhost:5222", new GrpcChannelOptions
            //{
            //    HttpHandler = new SocketsHttpHandler
            //    {
            //        EnableMultipleHttp2Connections = true,
            //        // 添加 TLS 验证绕过（仅开发环境）
            //        SslOptions = new SslClientAuthenticationOptions
            //        {
            //            RemoteCertificateValidationCallback = (_, _, _, _) => true
            //        }
            //    }
            //});

            Stopwatch sw = Stopwatch.StartNew();

            var d = new StatusPulishServer.StatusPulishServerClient(grpcChannel);

            var disStatus = d.QueryDISStatus(new Google.Protobuf.WellKnownTypes.Empty());
            var quenuInfos = d.QueryQueueInfos(new Google.Protobuf.WellKnownTypes.Empty());
            var clientInfos = d.QueryClientList(new Google.Protobuf.WellKnownTypes.Empty());

            sw.Start();
            var hisRecordQueryInfos = d.QueryHisRecordTable(new Google.Protobuf.WellKnownTypes.Empty());

            sw.Stop();

            Console.WriteLine($"时间：{sw.ElapsedMilliseconds}");
            var hisRecordSetinfos = d.SetHisRecordTable(new HisRecordTableSetRequest());

        }
        catch (Exception ex)
        {
        }

        Console.WriteLine("Hello, World!");
        Console.ReadLine();
    }
}
